package com.lzq.client01.Controller;

import com.lzq.client01.Entity.Customer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
public class searchController {

    @Value("${server.port}")
    private String port;

    @GetMapping("/search")
    public String search(){
        return "search" + port;
    }

    @GetMapping("/search/{id}")
    public Customer findByid(@PathVariable Integer id){
        return new Customer(1,"zhangsan",22);
    }

    @GetMapping("/getCustomer")
    public Customer getCustomer(@RequestParam Integer id, @RequestParam String name){
        return new Customer(1,name,22);
    }

    @PostMapping("/save")//会自动转为POST请求，出现405错误
    public Customer save(@RequestBody Customer customer){
        return customer;
    }

}
